//------------------------------------------------------------------------------
// <copyright file="IRpcMessageHandler.h" company="Microsoft">
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// </copyright>
//------------------------------------------------------------------------------

#pragma once

#include "RpcAnnotations.h"
#include "IRpcChannel.h"

namespace Microsoft { namespace Internal { namespace GamesTest { namespace Rpc { namespace Server
{
	class RpcRequest;

	/// <summary>
	/// Implemenations of this interface are used to handle incoming messages received from clients.
	/// Outgoing messages are intended to be sent using the provided IRpcChannel object.
	/// </summary>
	class IRpcMessageHandler
	{
	public:
		/// <summary>
		/// The method to be invoked with any message is received from a client. The message will be directed to the appropriate processing
		/// queue or processed immediately if appropriate.
		/// </summary>
		virtual HRESULT ProcessIncomingMessage(std::weak_ptr<IRpcChannel> channel, const std::wstring& message) = 0;

		/// <summary>
		/// This method shall process all pending requests that have been received.
		/// </summary>
		virtual HRESULT ProcessPendingRequests() = 0;

		/// <summary>
		/// This method should do any work necessary to clean up resources being held for a client that has disconnected.
		/// </summary>
		virtual void ClientDisconnected(std::weak_ptr<IRpcChannel> client) = 0;
	};

}}}}}